# -*- coding:utf-8 -*-
"""
@文件 redis.py
@Time : 2025/2/24
@Author: zjj
@Des: redis 配置文件
@Email: 1065377805@qq.com
"""

import redis.asyncio as redis
from redis.exceptions import ConnectionError, TimeoutError

redis_pool = redis.ConnectionPool(
    host='127.0.0.1',
    port=6379,
    # password='<PASSWORD>'
    decode_responses=True,
    encoding="utf-8"
)


async def redis_connect():
    try:
        redis_client = redis.Redis(connection_pool=redis_pool)
        sig = await redis_client.ping()
        print(sig)
        return redis_client
    except ConnectionError:
        print('redis 连接错误')
    except TimeoutError:
        print('redis 连接超时')
    except Exception as e:
        print('redis 连接异常')
